package com.truckdispatching.image;

import java.io.File;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.DisplayMetrics;

public class ImageTask implements Runnable {
	protected int Priority = -200;
	protected File mImageFile = null;
	protected String mImageUrl = "";

	protected volatile ImageTaskListener mListener;
	protected volatile boolean isReturnBitmap = true;

	protected volatile boolean isCancel = false;

	public ImageTask() {

	}

	public ImageTask(ImageTask task) {
		mImageFile = task.mImageFile;
		mImageUrl = task.mImageUrl;
	}

	public ImageTask(File saveFile, String imageUrl) {
		mImageFile = saveFile;
		mImageUrl = imageUrl;
	}

	public void cancel() {
		isCancel = true;
		isReturnBitmap = false;
		mListener = null;
	}

	public void setImageTaskListener(ImageTaskListener listener) {
		this.mListener = listener;
		this.isReturnBitmap = true;
	}

	public void setImageTaskListener(ImageTaskListener listener, boolean isReturnBitmap) {
		this.mListener = listener;
		this.isReturnBitmap = isReturnBitmap;
	}

	public void setIsReturnBitmap(boolean isReturnBitmap) {
		this.isReturnBitmap = isReturnBitmap;
	}

	protected BitmapFactory.Options getBitmapOptions() {
		BitmapFactory.Options options = new BitmapFactory.Options();
		options.inPreferredConfig = Bitmap.Config.RGB_565;
		options.inDither = true;
		options.inScaled = true;
		options.inTargetDensity = DisplayMetrics.DENSITY_DEFAULT;
		options.inDensity = DisplayMetrics.DENSITY_HIGH;
		return options;
	}

	@Override
	public void run() {

	}
}
